
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>6.使用Vue cli3搭建组件库并发布到 npm · Gary的小窝</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gary">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="microFE.html" />
    
    
    <link rel="prev" href="call.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    写在前面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../leetcode/">
            
                <a href="../leetcode/">
            
                    
                    Leetcode之旅
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../leetcode/1.html">
            
                <a href="../leetcode/1.html">
            
                    
                    1.两数之和
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../leetcode/2.html">
            
                <a href="../leetcode/2.html">
            
                    
                    2.两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../leetcode/3.html">
            
                <a href="../leetcode/3.html">
            
                    
                    3.无重复字符的最长子串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../leetcode/4.html">
            
                <a href="../leetcode/4.html">
            
                    
                    4.寻找两个有序数组的中位数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../leetcode/6.html">
            
                <a href="../leetcode/6.html">
            
                    
                    6.Z字形变换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../leetcode/9.html">
            
                <a href="../leetcode/9.html">
            
                    
                    9.回文数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../leetcode/11.html">
            
                <a href="../leetcode/11.html">
            
                    
                    11.盛最多水的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../leetcode/12.html">
            
                <a href="../leetcode/12.html">
            
                    
                    12.整数转罗马数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../leetcode/13.html">
            
                <a href="../leetcode/13.html">
            
                    
                    13.罗马数字转整数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../leetcode/14.html">
            
                <a href="../leetcode/14.html">
            
                    
                    14.最长公共前缀
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../leetcode/322.html">
            
                <a href="../leetcode/322.html">
            
                    
                    322.零钱兑换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../leetcode/72.html">
            
                <a href="../leetcode/72.html">
            
                    
                    72.编辑距离
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../flutter/">
            
                <a href="../flutter/">
            
                    
                    Flutter从入门到放弃
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../flutter/dart1.html">
            
                <a href="../flutter/dart1.html">
            
                    
                    1.Dart语言(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../flutter/dart2.html">
            
                <a href="../flutter/dart2.html">
            
                    
                    2.Dart语言(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../flutter/widget1.html">
            
                <a href="../flutter/widget1.html">
            
                    
                    3.Flutter初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../flutter/containerText.html">
            
                <a href="../flutter/containerText.html">
            
                    
                    4.Container和Text组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../flutter/image.html">
            
                <a href="../flutter/image.html">
            
                    
                    5.Image组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../flutter/chapter2.html">
            
                <a href="../flutter/chapter2.html">
            
                    
                    6.Flutter 技术总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue组件精讲
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/1.html">
            
                <a href="../vue/1.html">
            
                    
                    1.provide/inject
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/2.html">
            
                <a href="../vue/2.html">
            
                    
                    2.手动实现broadcast和dispatch方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="form.html">
            
                <a href="form.html">
            
                    
                    3.自己动手实现带校验的Form表单组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    JavaScript进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="proxy.html">
            
                <a href="proxy.html">
            
                    
                    1.Vue.js 3.0中的响应式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="el.html">
            
                <a href="el.html">
            
                    
                    2.Element UI 源码初探
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="bind.html">
            
                <a href="bind.html">
            
                    
                    3.bind的模拟实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="proto.html">
            
                <a href="proto.html">
            
                    
                    4.JS原型和原型链
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="call.html">
            
                <a href="call.html">
            
                    
                    5.模拟实现call和apply
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.6" data-path="ui.html">
            
                <a href="ui.html">
            
                    
                    6.使用Vue cli3搭建组件库并发布到 npm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="microFE.html">
            
                <a href="microFE.html">
            
                    
                    7.记一次基于qiankun的微前端的改造
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="git.html">
            
                <a href="git.html">
            
                    
                    8.Git的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vueLibrary/">
            
                <a href="../vueLibrary/">
            
                    
                    基于Vue的PC端的组件库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vueLibrary/1.html">
            
                <a href="../vueLibrary/1.html">
            
                    
                    1.环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../life/">
            
                <a href="../life/">
            
                    
                    网事杂谈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../life/1.html">
            
                <a href="../life/1.html">
            
                    
                    1.周杰伦专辑赏析--叶惠美
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../life/2.html">
            
                <a href="../life/2.html">
            
                    
                    2.周杰伦专辑赏析--七里香
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >6.使用Vue cli3搭建组件库并发布到 npm</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x8BE6;&#x89E3;&#xFF1A;vue-cli3-&#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230;-npm&#x6D41;&#x7A0B;"><b></b>&#x8BE6;&#x89E3;&#xFF1A;Vue cli3 &#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230; npm&#x6D41;&#x7A0B;</a></li><ul><li><span class="title-icon "></span><a href="#&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;"><b></b>&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;</a></li><li><span class="title-icon "></span><a href="#&#x6D41;&#x7A0B;"><b></b>&#x6D41;&#x7A0B;</a></li><li><span class="title-icon "></span><a href="#&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><b></b>&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x521B;&#x5EFA;&#x9879;&#x76EE;"><b></b>1.&#x521B;&#x5EFA;&#x9879;&#x76EE;</a></li><li><span class="title-icon "></span><a href="#2&#x8C03;&#x6574;&#x76EE;&#x5F55;"><b></b>2.&#x8C03;&#x6574;&#x76EE;&#x5F55;</a></li></ul><li><span class="title-icon "></span><a href="#&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><b></b>&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-pages-&#x9009;&#x9879;"><b></b>1.&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684; pages &#x9009;&#x9879;</a></li><li><span class="title-icon "></span><a href="#2&#x652F;&#x6301;&#x5BF9;-packages-&#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-chainwebpack-&#x9009;&#x9879;"><b></b>2.&#x652F;&#x6301;&#x5BF9; packages &#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684; chainWebpack &#x9009;&#x9879;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7F16;&#x5199;&#x7EC4;&#x4EF6;"><b></b>&#x7F16;&#x5199;&#x7EC4;&#x4EF6;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;"><b></b>1.&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#2&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><b></b>2.&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7F16;&#x5199;&#x793A;&#x4F8B;"><b></b>&#x7F16;&#x5199;&#x793A;&#x4F8B;</a></li><ul><li><span class="title-icon "></span><a href="#1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;"><b></b>1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;</a></li><li><span class="title-icon "></span><a href="#2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;"><b></b>2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;</a></li></ul><li><span class="title-icon "></span><a href="#&#x53D1;&#x5E03;&#x5230;-npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;"><b></b>&#x53D1;&#x5E03;&#x5230; npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;</a></li><ul><li><span class="title-icon "></span><a href="#1packagejson-&#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;"><b></b>1.package.json &#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;</a></li><li><span class="title-icon "></span><a href="#2&#x914D;&#x7F6E;-packagejson-&#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230;-npm-&#x7684;&#x5B57;&#x6BB5;"><b></b>2.&#x914D;&#x7F6E; package.json &#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230; npm &#x7684;&#x5B57;&#x6BB5;</a></li><li><span class="title-icon "></span><a href="#3&#x6DFB;&#x52A0;-npmignore-&#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;"><b></b>3.&#x6DFB;&#x52A0; .npmignore &#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#4&#x767B;&#x5F55;&#x5230;-npm"><b></b>4.&#x767B;&#x5F55;&#x5230; npm</a></li><li><span class="title-icon "></span><a href="#5&#x53D1;&#x5E03;&#x5230;-npm"><b></b>5.&#x53D1;&#x5E03;&#x5230; npm</a></li><li><span class="title-icon "></span><a href="#6&#x53D1;&#x5E03;&#x6210;&#x529F;"><b></b>6.&#x53D1;&#x5E03;&#x6210;&#x529F;</a></li><li><span class="title-icon "></span><a href="#7&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><b></b>7.&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;</a></li></ul><li><span class="title-icon "></span><a href="#&#x53C2;&#x8003;&#x6587;&#x7AE0;"><b></b>&#x53C2;&#x8003;&#x6587;&#x7AE0;</a></li></ul></ul></div><a href="#&#x8BE6;&#x89E3;&#xFF1A;vue-cli3-&#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230;-npm&#x6D41;&#x7A0B;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x8BE6;&#x89E3;&#xFF1A;vue-cli3-&#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230;-npm&#x6D41;&#x7A0B;"><a name="&#x8BE6;&#x89E3;&#xFF1A;vue-cli3-&#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230;-npm&#x6D41;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x8BE6;&#x89E3;&#xFF1A;vue-cli3-&#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230;-npm&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8BE6;&#x89E3;&#xFF1A;Vue cli3 &#x5E93;&#x6A21;&#x5F0F;&#x642D;&#x5EFA;&#x7EC4;&#x4EF6;&#x5E93;&#x5E76;&#x53D1;&#x5E03;&#x5230; npm&#x6D41;&#x7A0B;</h1>
<blockquote>
<p>&#x672C;&#x6587;&#x7684;&#x76EE;&#x7684;&#x5C31;&#x662F;&#x8BA9;&#x8BFB;&#x8005;&#x80FD;&#x901A;&#x8FC7;&#x6B64;&#x6587;&#xFF0C;&#x5C0F;&#x80FD;&#x505A;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x63D2;&#x4EF6;&#x4F9B;&#x4EBA;&#x4F7F;&#x7528;&#xFF0C;&#x5927;&#x80FD;&#x67B6;&#x6784;&#x548C;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x5E93;&#x4E0D;&#x5728;&#x8BDD;&#x4E0B;&#x3002;&#x4EE5;&#x4E0B;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x989C;&#x8272;&#x9009;&#x62E9;&#x5668;&#x63D2;&#x4EF6;vColorPicker&#x8BB2;&#x8FF0;&#x4ECE;&#x5F00;&#x53D1;&#x5230;&#x4E0A;&#x7EBF;&#x5230;npm&#x7684;&#x6D41;&#x7A0B;&#x3002;</p>
</blockquote>
<h2 id="&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;"><a name="&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;" class="anchor-navigation-ex-anchor" href="#&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7528;&#x5230;&#x7684;&#x6280;&#x672F;&#x6808;</h2>
<p>&#x5982;&#x4F55;&#x901A;&#x8FC7;&#x65B0;&#x7248;&#x811A;&#x624B;&#x67B6;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x63D0;&#x4E86;&#xFF0C;&#x81EA;&#x884C;&#x770B;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x3002;</p>
<ol>
<li>Vue-cli3: &#x65B0;&#x7248;&#x811A;&#x624B;&#x67B6;&#x7684;&#x5E93;&#x6A21;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x8BA9;&#x6211;&#x4EEC;&#x5F88;&#x8F7B;&#x677E;&#x7684;&#x521B;&#x5EFA;&#x6253;&#x5305;&#x4E00;&#x4E2A;&#x5E93;&#xFF08;&#x4F7F;&#x7528;&#x811A;&#x624B;&#x67B6;&#x7248;&#x672C;3.8.3&#xFF09;</li>
<li>npm&#xFF1A;&#x7EC4;&#x4EF6;&#x5E93;&#x5C06;&#x5B58;&#x653E;&#x5728;npm</li>
<li>webpack&#xFF1A;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x9700;&#x8981;&#x4E00;&#x70B9; webapck &#x7684;&#x77E5;&#x8BC6;&#x3002;</li>
</ol>
<h2 id="&#x6D41;&#x7A0B;"><a name="&#x6D41;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6D41;&#x7A0B;</h2>
<p>&#x60F3;&#x8981;&#x642D;&#x5EFA;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x5E93;&#xFF0C;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x5148;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x5927;&#x6982;&#x7684;&#x601D;&#x8DEF;&#x3002;</p>
<ol>
<li>&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</li>
<li>&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</li>
<li>&#x7F16;&#x5199;&#x7EC4;&#x4EF6;</li>
<li>&#x7F16;&#x5199;&#x793A;&#x4F8B;</li>
<li>&#x914D;&#x7F6E;&#x4F7F;&#x7528;&#x5E93;&#x6A21;&#x5F0F;&#x6253;&#x5305;&#x7F16;&#x8BD1;</li>
<li>&#x53D1;&#x5E03;&#x5230;npm</li>
</ol>
<h2 id="&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><a name="&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;" class="anchor-navigation-ex-anchor" href="#&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89C4;&#x5212;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</h2>
<h3 id="1&#x521B;&#x5EFA;&#x9879;&#x76EE;"><a name="1&#x521B;&#x5EFA;&#x9879;&#x76EE;" class="anchor-navigation-ex-anchor" href="#1&#x521B;&#x5EFA;&#x9879;&#x76EE;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x521B;&#x5EFA;&#x9879;&#x76EE;</h3>
<p>&#x5728;&#x6307;&#x5B9A;&#x76EE;&#x5F55;&#x4E2D;&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9ED8;&#x8BA4;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x6216;&#x8005;&#x6839;&#x636E;&#x81EA;&#x5DF1;&#x9700;&#x8981;&#x81EA;&#x5DF1;&#x9009;&#x62E9;&#x3002;</p>
<pre class="language-"><code class="lang-js">$ vue create <span class="token punctuation">.</span>
</code></pre>
<h3 id="2&#x8C03;&#x6574;&#x76EE;&#x5F55;"><a name="2&#x8C03;&#x6574;&#x76EE;&#x5F55;" class="anchor-navigation-ex-anchor" href="#2&#x8C03;&#x6574;&#x76EE;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x8C03;&#x6574;&#x76EE;&#x5F55;</h3>
<p>&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x5B58;&#x653E;&#x7EC4;&#x4EF6;&#xFF0C;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x5B58;&#x653E;&#x793A;&#x4F8B;&#xFF0C;&#x6309;&#x7167;&#x4EE5;&#x4E0B;&#x65B9;&#x5F0F;&#x5BF9;&#x76EE;&#x5F55;&#x8FDB;&#x884C;&#x6539;&#x9020;&#x3002;</p>
<blockquote>
<p> &#x4E3A;&#x4EC0;&#x4E48;&#x8981;&#x8FD9;&#x4E48;&#x6539;&#x5462;&#xFF1F; &#x56E0;&#x4E3A; &#x6211;&#x770B;&#x4E86;Element UI &#x6E90;&#x7801; &#x5C31;&#x662F;&#x8FD9;&#x4E48;&#x6574;&#x7684;QAQ&#xFF0C;&#x7AD9;&#x5728;&#x5DE8;&#x4EBA;&#x7684;&#x80A9;&#x8180;&#x4E0A;&#x7F16;&#x7A0B;&#x3002;</p>
<pre class="language-"><code class="lang-js"><span class="token punctuation">.</span>
<span class="token operator">...</span>
<span class="token operator">|</span><span class="token operator">--</span> examples      <span class="token comment">// &#x539F; src &#x76EE;&#x5F55;&#xFF0C;&#x6539;&#x6210; examples &#x7528;&#x4F5C;&#x793A;&#x4F8B;&#x5C55;&#x793A;</span>
<span class="token operator">|</span><span class="token operator">--</span> packages      <span class="token comment">// &#x65B0;&#x589E; packages &#x7528;&#x4E8E;&#x7F16;&#x5199;&#x5B58;&#x653E;&#x7EC4;&#x4EF6;</span>
<span class="token operator">...</span>
<span class="token punctuation">.</span>
</code></pre>
<h2 id="&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><a name="&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;" class="anchor-navigation-ex-anchor" href="#&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x4EE5;&#x652F;&#x6301;&#x65B0;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</h2>
<p>&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x4E0A;&#x4E00;&#x6B65;&#x7684;&#x76EE;&#x5F55;&#x6539;&#x9020;&#x540E;&#xFF0C;&#x4F1A;&#x9047;&#x5230;&#x4E24;&#x4E2A;&#x95EE;&#x9898;&#x3002;</p>
</blockquote>
<ol>
<li>src&#x76EE;&#x5F55;&#x66F4;&#x540D;&#x4E3A;examples&#xFF0C;&#x5BFC;&#x81F4;&#x9879;&#x76EE;&#x65E0;&#x6CD5;&#x8FD0;&#x884C;</li>
<li>&#x65B0;&#x589E;packages&#x76EE;&#x5F55;&#xFF0C;&#x8BE5;&#x76EE;&#x5F55;&#x672A;&#x52A0;&#x5165;webpack&#x7F16;&#x8BD1;</li>
</ol>
<p>&#x6CE8;&#xFF1A;cli3 &#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x53EF;&#x9009;&#x7684; vue.config.js &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;&#x5982;&#x679C;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5B58;&#x5728;&#x5219;&#x4ED6;&#x4F1A;&#x88AB;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x5BF9;&#x9879;&#x76EE;&#x548C;webpack&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x90FD;&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x3002;</p>
<h3 id="1&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-pages-&#x9009;&#x9879;"><a name="1&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-pages-&#x9009;&#x9879;" class="anchor-navigation-ex-anchor" href="#1&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-pages-&#x9009;&#x9879;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x91CD;&#x65B0;&#x914D;&#x7F6E;&#x5165;&#x53E3;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684; pages &#x9009;&#x9879;</h3>
<p>&#x65B0;&#x7248; Vue CLI &#x652F;&#x6301;&#x4F7F;&#x7528; vue.config.js &#x4E2D;&#x7684; pages &#x9009;&#x9879;&#x6784;&#x5EFA;&#x4E00;&#x4E2A;&#x591A;&#x9875;&#x9762;&#x7684;&#x5E94;&#x7528;&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x4F7F;&#x7528; pages &#x4FEE;&#x6539;&#x5165;&#x53E3;&#x5230; examples</p>
<pre class="language-"><code class="lang-js">module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x4FEE;&#x6539; src &#x76EE;&#x5F55; &#x4E3A; examples &#x76EE;&#x5F55;</span>
  pages<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    index<span class="token punctuation">:</span> <span class="token punctuation">{</span>
      entry<span class="token punctuation">:</span> <span class="token string">&apos;examples/main.js&apos;</span><span class="token punctuation">,</span>
      template<span class="token punctuation">:</span> <span class="token string">&apos;public/index.html&apos;</span><span class="token punctuation">,</span>
      filename<span class="token punctuation">:</span> <span class="token string">&apos;index.html&apos;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="2&#x652F;&#x6301;&#x5BF9;-packages-&#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-chainwebpack-&#x9009;&#x9879;"><a name="2&#x652F;&#x6301;&#x5BF9;-packages-&#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-chainwebpack-&#x9009;&#x9879;" class="anchor-navigation-ex-anchor" href="#2&#x652F;&#x6301;&#x5BF9;-packages-&#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684;-chainwebpack-&#x9009;&#x9879;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x652F;&#x6301;&#x5BF9; packages &#x76EE;&#x5F55;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x4E2D;&#x7684; chainWebpack &#x9009;&#x9879;</h3>
<p>packages &#x662F;&#x6211;&#x4EEC;&#x65B0;&#x589E;&#x7684;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#xFF0C;&#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x88AB; webpack &#x5904;&#x7406;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x5BF9;&#x8BE5;&#x76EE;&#x5F55;&#x7684;&#x652F;&#x6301;&#x3002;</p>
<p>chainWebpack &#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x4F1A;&#x63A5;&#x6536;&#x4E00;&#x4E2A;&#x57FA;&#x4E8E; webpack-chain &#x7684; ChainableConfig &#x5B9E;&#x4F8B;&#x3002;&#x5141;&#x8BB8;&#x5BF9;&#x5185;&#x90E8;&#x7684; webpack &#x914D;&#x7F6E;&#x8FDB;&#x884C;&#x66F4;&#x7EC6;&#x7C92;&#x5EA6;&#x7684;&#x4FEE;&#x6539;&#x3002;</p>
<pre class="language-"><code class="lang-js">module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x4FEE;&#x6539; src &#x4E3A; examples</span>
  pages<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    index<span class="token punctuation">:</span> <span class="token punctuation">{</span>
      entry<span class="token punctuation">:</span> <span class="token string">&apos;examples/main.js&apos;</span><span class="token punctuation">,</span>
      template<span class="token punctuation">:</span> <span class="token string">&apos;public/index.html&apos;</span><span class="token punctuation">,</span>
      filename<span class="token punctuation">:</span> <span class="token string">&apos;index.html&apos;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token comment">// &#x6269;&#x5C55; webpack &#x914D;&#x7F6E;&#xFF0C;&#x4F7F; packages &#x52A0;&#x5165;&#x7F16;&#x8BD1;</span>
  <span class="token function-variable function">chainWebpack</span><span class="token punctuation">:</span> <span class="token parameter">config</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    config<span class="token punctuation">.</span>module
      <span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">&apos;js&apos;</span><span class="token punctuation">)</span>
      <span class="token punctuation">.</span>include
        <span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token string">&apos;/packages&apos;</span><span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
      <span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token string">&apos;babel&apos;</span><span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">&apos;babel-loader&apos;</span><span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">tap</span><span class="token punctuation">(</span><span class="token parameter">options</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
          <span class="token comment">// &#x4FEE;&#x6539;&#x5B83;&#x7684;&#x9009;&#x9879;...</span>
          <span class="token keyword">return</span> options
        <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5173;&#x4E8E;webpack&#x7684;&#x94FE;&#x5F0F;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x770B; <a href="https://cli.vuejs.org/zh/guide/webpack.html#%E9%93%BE%E5%BC%8F%E6%93%8D%E4%BD%9C-%E9%AB%98%E7%BA%A7" target="_blank">&#x8FD9;&#x91CC;</a> &#x5566;&#x3002;</p>
<h2 id="&#x7F16;&#x5199;&#x7EC4;&#x4EF6;"><a name="&#x7F16;&#x5199;&#x7EC4;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x7F16;&#x5199;&#x7EC4;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7F16;&#x5199;&#x7EC4;&#x4EF6;</h2>
<p>&#x4EE5;&#x4E0A;&#x6211;&#x4EEC;&#x5DF2;&#x914D;&#x7F6E;&#x597D;&#x5BF9;&#x65B0;&#x76EE;&#x5F55;&#x67B6;&#x6784;&#x7684;&#x652F;&#x6301;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5C1D;&#x8BD5;&#x7F16;&#x5199;&#x7EC4;&#x4EF6;&#x3002;&#x4EE5;&#x4E0B;&#x6211;&#x4EEC;&#x4EE5;&#x4E00;&#x4E2A;&#x5DF2;&#x53D1;&#x5E03;&#x5230; npm &#x7684;&#x5C0F;&#x63D2;&#x4EF6;&#x4F5C;&#x4E3A;&#x793A;&#x4F8B;&#x3002;</p>
<p>GitHub - <a href="https://github.com/zuley/vue-color-picker" target="_blank">&#x989C;&#x8272;&#x9009;&#x62E9;&#x5668;-vcolorpicker</a></p>
<h3 id="1&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;"><a name="1&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#1&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7EC4;&#x4EF6;</h3>
<ol>
<li>&#x5728; packages &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x5355;&#x4E2A;&#x7EC4;&#x4EF6;&#x90FD;&#x4EE5;&#x6587;&#x4EF6;&#x5939;&#x7684;&#x5F62;&#x5F0F;&#x5B58;&#x50A8;&#xFF0C;&#x6240;&#x6709;&#x8FD9;&#x91CC;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x76EE;&#x5F55; color-picker/</li>
<li>&#x5728; color-picker/ &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA; src/ &#x76EE;&#x5F55;&#x5B58;&#x50A8;&#x7EC4;&#x4EF6;&#x6E90;&#x7801;</li>
<li>&#x5728; /color-picker &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA; index.js &#x6587;&#x4EF6;&#x5BF9;&#x5916;&#x63D0;&#x4F9B;&#x5BF9;&#x7EC4;&#x4EF6;&#x7684;&#x5F15;&#x7528;&#x3002;</li>
</ol>
<p>&#x4FEE;&#x6539; /packages/color-picker/index.js&#x6587;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x63D0;&#x4F9B;&#x5F15;&#x7528;&#x3002;</p>
<pre class="language-"><code class="lang-js"># <span class="token operator">/</span>packages<span class="token operator">/</span>color<span class="token operator">-</span>picker<span class="token operator">/</span>index<span class="token punctuation">.</span>js
<span class="token comment">// &#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#xFF0C;&#x7EC4;&#x4EF6;&#x5FC5;&#x987B;&#x58F0;&#x660E; name</span>
<span class="token keyword">import</span> colorPicker <span class="token keyword">from</span> <span class="token string">&apos;./src/color-picker.vue&apos;</span>

<span class="token comment">// &#x4E3A;&#x7EC4;&#x4EF6;&#x63D0;&#x4F9B; install &#x5B89;&#x88C5;&#x65B9;&#x6CD5;&#xFF0C;&#x4F9B;&#x6309;&#x9700;&#x5F15;&#x5165;</span>
colorPicker<span class="token punctuation">.</span><span class="token function-variable function">install</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">Vue</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  Vue<span class="token punctuation">.</span><span class="token function">component</span><span class="token punctuation">(</span>colorPicker<span class="token punctuation">.</span>name<span class="token punctuation">,</span> colorPicker<span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x9ED8;&#x8BA4;&#x5BFC;&#x51FA;&#x7EC4;&#x4EF6;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> colorPicker
</code></pre>
<h3 id="2&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><a name="2&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;" class="anchor-navigation-ex-anchor" href="#2&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x6574;&#x5408;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x5BF9;&#x5916;&#x5BFC;&#x51FA;&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;</h3>
<p>&#x4FEE;&#x6539; /packages/index.js &#x6587;&#x4EF6;&#xFF0C;&#x5BF9;&#x6574;&#x4E2A;&#x7EC4;&#x4EF6;&#x5E93;&#x8FDB;&#x884C;&#x5BFC;&#x51FA;&#x3002;</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// &#x5BFC;&#x5165;&#x989C;&#x8272;&#x9009;&#x62E9;&#x5668;&#x7EC4;&#x4EF6;</span>
<span class="token keyword">import</span> colorPicker <span class="token keyword">from</span> <span class="token string">&apos;./color-picker&apos;</span>

<span class="token comment">// &#x5B58;&#x50A8;&#x7EC4;&#x4EF6;&#x5217;&#x8868;</span>
<span class="token keyword">const</span> components <span class="token operator">=</span> <span class="token punctuation">[</span>
  colorPicker
<span class="token punctuation">]</span>

<span class="token comment">// &#x5B9A;&#x4E49; install &#x65B9;&#x6CD5;&#xFF0C;&#x63A5;&#x6536; Vue &#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x3002;&#x5982;&#x679C;&#x4F7F;&#x7528; use &#x6CE8;&#x518C;&#x63D2;&#x4EF6;&#xFF0C;&#x5219;&#x6240;&#x6709;&#x7684;&#x7EC4;&#x4EF6;&#x90FD;&#x5C06;&#x88AB;&#x6CE8;&#x518C;</span>
<span class="token keyword">const</span> <span class="token function-variable function">install</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">Vue</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x5224;&#x65AD;&#x662F;&#x5426;&#x5B89;&#x88C5;</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>install<span class="token punctuation">.</span>installed<span class="token punctuation">)</span> <span class="token keyword">return</span>
  <span class="token comment">// &#x904D;&#x5386;&#x6CE8;&#x518C;&#x5168;&#x5C40;&#x7EC4;&#x4EF6;</span>
  components<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token parameter">component</span> <span class="token operator">=&gt;</span> Vue<span class="token punctuation">.</span><span class="token function">component</span><span class="token punctuation">(</span>component<span class="token punctuation">.</span>name<span class="token punctuation">,</span> component<span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x76F4;&#x63A5;&#x5F15;&#x5165;&#x6587;&#x4EF6;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">typeof</span> window <span class="token operator">!==</span> <span class="token string">&apos;undefined&apos;</span> <span class="token operator">&amp;&amp;</span> window<span class="token punctuation">.</span>Vue<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">install</span><span class="token punctuation">(</span>window<span class="token punctuation">.</span>Vue<span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x5BFC;&#x51FA;&#x7684;&#x5BF9;&#x8C61;&#x5FC5;&#x987B;&#x5177;&#x6709; install&#xFF0C;&#x624D;&#x80FD;&#x88AB; Vue.use() &#x65B9;&#x6CD5;&#x5B89;&#x88C5;</span>
  install<span class="token punctuation">,</span>
  <span class="token comment">// &#x4EE5;&#x4E0B;&#x662F;&#x5177;&#x4F53;&#x7684;&#x7EC4;&#x4EF6;&#x5217;&#x8868;</span>
  colorPicker
<span class="token punctuation">}</span>
</code></pre>
<h2 id="&#x7F16;&#x5199;&#x793A;&#x4F8B;"><a name="&#x7F16;&#x5199;&#x793A;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x7F16;&#x5199;&#x793A;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7F16;&#x5199;&#x793A;&#x4F8B;</h2>
<h3 id="1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;"><a name="1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;" class="anchor-navigation-ex-anchor" href="#1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;</h3>
<pre class="language-"><code class="lang-js"><span class="token keyword">import</span> Vue <span class="token keyword">from</span> <span class="token string">&apos;vue&apos;</span>
<span class="token keyword">import</span> App <span class="token keyword">from</span> <span class="token string">&apos;./App.vue&apos;</span>

<span class="token comment">// &#x5BFC;&#x5165;&#x7EC4;&#x4EF6;&#x5E93;</span>
<span class="token keyword">import</span> ColorPicker <span class="token keyword">from</span> <span class="token string">&apos;./../packages/index&apos;</span>
<span class="token comment">// &#x6CE8;&#x518C;&#x7EC4;&#x4EF6;&#x5E93;</span>
Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>ColorPicker<span class="token punctuation">)</span>

Vue<span class="token punctuation">.</span>config<span class="token punctuation">.</span>productionTip <span class="token operator">=</span> <span class="token boolean">false</span>

<span class="token keyword">new</span> <span class="token class-name">Vue</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token function-variable function">render</span><span class="token punctuation">:</span> <span class="token parameter">h</span> <span class="token operator">=&gt;</span> <span class="token function">h</span><span class="token punctuation">(</span>App<span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">$mount</span><span class="token punctuation">(</span><span class="token string">&apos;#app&apos;</span><span class="token punctuation">)</span>
</code></pre>
<h3 id="2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;"><a name="2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;&#x5728;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;</h3>
<p>&#x5728;&#x4E0A;&#x4E00;&#x6B65;&#x7528;&#x4F7F;&#x7528; Vue.use() &#x5168;&#x5C40;&#x6CE8;&#x518C;&#x540E;&#xFF0C;&#x5373;&#x53EF;&#x5728;&#x4EFB;&#x610F;&#x9875;&#x9762;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x4E86;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x53E6;&#x5916;&#x5F15;&#x5165;&#x3002;&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x6309;&#x9700;&#x5F15;&#x5165;&#x3002;</p>
<pre class="language-"><code class="lang-js"><span class="token operator">&lt;</span>template<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>colorPicker v<span class="token operator">-</span>model<span class="token operator">=</span><span class="token string">&quot;color&quot;</span> v<span class="token operator">-</span>on<span class="token punctuation">:</span>change<span class="token operator">=</span><span class="token string">&quot;headleChangeColor&quot;</span><span class="token operator">&gt;</span><span class="token operator">&lt;</span><span class="token operator">/</span>colorPicker<span class="token operator">&gt;</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>template<span class="token operator">&gt;</span>

<span class="token operator">&lt;</span>script<span class="token operator">&gt;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
    <span class="token function">data</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">{</span>
            color<span class="token punctuation">:</span> <span class="token string">&apos;#ff0000&apos;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    methods<span class="token punctuation">:</span> <span class="token punctuation">{</span>
        <span class="token function">headleChangeColor</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;&#x989C;&#x8272;&#x6539;&#x53D8;&apos;</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">&gt;</span>
</code></pre>
<h2 id="&#x53D1;&#x5E03;&#x5230;-npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;"><a name="&#x53D1;&#x5E03;&#x5230;-npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x53D1;&#x5E03;&#x5230;-npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D1;&#x5E03;&#x5230; npm&#xFF0C;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;</h2>
<p>&#x5230;&#x6B64;&#x4E3A;&#x6B62;&#x6211;&#x4EEC;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;&#x5DF2;&#x7ECF;&#x5F00;&#x53D1;&#x5B8C;&#x6210;&#x4E86;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x5C31;&#x662F;&#x53D1;&#x5E03;&#x5230; npm &#x4EE5;&#x4F9B;&#x540E;&#x671F;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="1packagejson-&#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;"><a name="1packagejson-&#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;" class="anchor-navigation-ex-anchor" href="#1packagejson-&#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.package.json &#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x7F16;&#x8BD1;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x4EE4;</h3>
<p>&#x5728;&#x5E93;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;Vue&#x662F;&#x5916;&#x7F6E;&#x7684;&#xFF0C;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x5373;&#x4F7F;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x5F15;&#x5165;&#x4E86; Vue&#xFF0C;&#x6253;&#x5305;&#x540E;&#x7684;&#x6587;&#x4EF6;&#x4E5F;&#x662F;&#x4E0D;&#x5305;&#x542B;Vue&#x7684;&#x3002;</p>
<p><a href="https://cli.vuejs.org/zh/guide/build-targets.html#&#x5E93;" target="_blank">Vue Cli3 &#x6784;&#x5EFA;&#x76EE;&#x6807;&#xFF1A;&#x5E93;</a></p>
<p>&#x4EE5;&#x4E0B;&#x6211;&#x4EEC;&#x5728; scripts &#x4E2D;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x547D;&#x4EE4; npm run lib</p>
<ul>
<li>--target: &#x6784;&#x5EFA;&#x76EE;&#x6807;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x5E94;&#x7528;&#x6A21;&#x5F0F;&#x3002;&#x8FD9;&#x91CC;&#x4FEE;&#x6539;&#x4E3A; lib &#x542F;&#x7528;&#x5E93;&#x6A21;&#x5F0F;&#x3002;</li>
<li>--dest : &#x8F93;&#x51FA;&#x76EE;&#x5F55;&#xFF0C;&#x9ED8;&#x8BA4; dist&#x3002;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x6539;&#x6210; lib</li>
<li>[entry]: &#x6700;&#x540E;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x5165;&#x53E3;&#x6587;&#x4EF6;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A; src/App.vue&#x3002;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x6307;&#x5B9A;&#x7F16;&#x8BD1; packages/ &#x7EC4;&#x4EF6;&#x5E93;&#x76EE;&#x5F55;&#x3002;<pre class="language-"><code class="lang-js"><span class="token string">&quot;scripts&quot;</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
  <span class="token comment">// ...</span>
  <span class="token string">&quot;lib&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;vue-cli-service build --target lib --name vcolorpicker --dest lib packages/index.js&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
&#x6267;&#x884C;&#x7F16;&#x8BD1;&#x5E93;&#x547D;&#x4EE4;<pre class="language-"><code class="lang-js">$ npm run lib
</code></pre>
<h3 id="2&#x914D;&#x7F6E;-packagejson-&#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230;-npm-&#x7684;&#x5B57;&#x6BB5;"><a name="2&#x914D;&#x7F6E;-packagejson-&#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230;-npm-&#x7684;&#x5B57;&#x6BB5;" class="anchor-navigation-ex-anchor" href="#2&#x914D;&#x7F6E;-packagejson-&#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230;-npm-&#x7684;&#x5B57;&#x6BB5;"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x914D;&#x7F6E; package.json &#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x5E03;&#x5230; npm &#x7684;&#x5B57;&#x6BB5;</h3>
</li>
<li>name: &#x5305;&#x540D;&#xFF0C;&#x8BE5;&#x540D;&#x5B57;&#x662F;&#x552F;&#x4E00;&#x7684;&#x3002;&#x53EF;&#x5728; npm &#x5B98;&#x7F51;&#x641C;&#x7D22;&#x540D;&#x5B57;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#x5219;&#x9700;&#x6362;&#x4E2A;&#x540D;&#x5B57;&#x3002;</li>
<li>version: &#x7248;&#x672C;&#x53F7;&#xFF0C;&#x6BCF;&#x6B21;&#x53D1;&#x5E03;&#x81F3; npm &#x9700;&#x8981;&#x4FEE;&#x6539;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x4E0D;&#x80FD;&#x548C;&#x5386;&#x53F2;&#x7248;&#x672C;&#x53F7;&#x76F8;&#x540C;&#x3002;</li>
<li>description: &#x63CF;&#x8FF0;&#x3002;</li>
<li>main: &#x5165;&#x53E3;&#x6587;&#x4EF6;&#xFF0C;&#x8BE5;&#x5B57;&#x6BB5;&#x9700;&#x6307;&#x5411;&#x6211;&#x4EEC;&#x6700;&#x7EC8;&#x7F16;&#x8BD1;&#x540E;&#x7684;&#x5305;&#x6587;&#x4EF6;&#x3002;</li>
<li>keyword&#xFF1A;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x4EE5;&#x7A7A;&#x683C;&#x5206;&#x79BB;&#x5E0C;&#x671B;&#x7528;&#x6237;&#x6700;&#x7EC8;&#x641C;&#x7D22;&#x7684;&#x8BCD;&#x3002;</li>
<li>author&#xFF1A;&#x4F5C;&#x8005;</li>
<li>private&#xFF1A;&#x662F;&#x5426;&#x79C1;&#x6709;&#xFF0C;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x4E3A; false &#x624D;&#x80FD;&#x53D1;&#x5E03;&#x5230; npm</li>
<li>license&#xFF1A; &#x5F00;&#x6E90;&#x534F;&#x8BAE;</li>
</ul>
<p>&#x4EE5;&#x4E0B;&#x4E3A;&#x53C2;&#x8003;&#x8BBE;&#x7F6E;</p>
<pre class="language-"><code class="lang-js"><span class="token punctuation">{</span>
  <span class="token string">&quot;name&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;vcolorpicker&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;version&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;0.1.5&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;description&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;&#x57FA;&#x4E8E; Vue &#x7684;&#x989C;&#x8272;&#x9009;&#x62E9;&#x5668;&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;main&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;lib/vcolorpicker.umd.min.js&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;keyword&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;vcolorpicker colorpicker color-picker&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;private&quot;</span><span class="token punctuation">:</span> <span class="token boolean">false</span>
 <span class="token punctuation">}</span>
</code></pre>
<h3 id="3&#x6DFB;&#x52A0;-npmignore-&#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;"><a name="3&#x6DFB;&#x52A0;-npmignore-&#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#3&#x6DFB;&#x52A0;-npmignore-&#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>3.&#x6DFB;&#x52A0; .npmignore &#x6587;&#x4EF6;&#xFF0C;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x53D1;&#x5E03;&#x6587;&#x4EF6;</h3>
<p>&#x6211;&#x4EEC;&#x53D1;&#x5E03;&#x5230; npm &#x4E2D;&#xFF0C;&#x53EA;&#x6709;&#x7F16;&#x8BD1;&#x540E;&#x7684; lib &#x76EE;&#x5F55;&#x3001;package.json&#x3001;README.md&#x624D;&#x662F;&#x9700;&#x8981;&#x88AB;&#x53D1;&#x5E03;&#x7684;&#x3002;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x8BBE;&#x7F6E;&#x5FFD;&#x7565;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#x3002;
&#x548C; .gitignore &#x7684;&#x8BED;&#x6CD5;&#x4E00;&#x6837;&#xFF0C;&#x5177;&#x4F53;&#x9700;&#x8981;&#x63D0;&#x4EA4;&#x4EC0;&#x4E48;&#x6587;&#x4EF6;&#xFF0C;&#x770B;&#x5404;&#x81EA;&#x7684;&#x5B9E;&#x9645;&#x60C5;&#x51B5;&#x3002;</p>
<pre class="language-"><code class="lang-js"># &#x5FFD;&#x7565;&#x76EE;&#x5F55;
examples<span class="token operator">/</span>
packages<span class="token operator">/</span>
<span class="token keyword">public</span><span class="token operator">/</span>

# &#x5FFD;&#x7565;&#x6307;&#x5B9A;&#x6587;&#x4EF6;
vue<span class="token punctuation">.</span>config<span class="token punctuation">.</span>js
babel<span class="token punctuation">.</span>config<span class="token punctuation">.</span>js
<span class="token operator">*</span><span class="token punctuation">.</span>map
</code></pre>
<h3 id="4&#x767B;&#x5F55;&#x5230;-npm"><a name="4&#x767B;&#x5F55;&#x5230;-npm" class="anchor-navigation-ex-anchor" href="#4&#x767B;&#x5F55;&#x5230;-npm"><i class="fa fa-link" aria-hidden="true"></i></a>4.&#x767B;&#x5F55;&#x5230; npm</h3>
<p>&#x9996;&#x5148;&#x9700;&#x8981;&#x5230; npm &#x4E0A;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x8D26;&#x53F7;&#xFF0C;&#x6CE8;&#x518C;&#x8FC7;&#x7A0B;&#x7565;&#x3002;</p>
<p>&#x5982;&#x679C;&#x914D;&#x7F6E;&#x4E86;&#x6DD8;&#x5B9D;&#x955C;&#x50CF;&#xFF0C;&#x5148;&#x8BBE;&#x7F6E;&#x56DE;npm&#x955C;&#x50CF;&#xFF1A;</p>
<pre class="language-"><code class="lang-js">$ npm config <span class="token keyword">set</span> registry http<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>registry<span class="token punctuation">.</span>npmjs<span class="token punctuation">.</span>org
</code></pre>
<p>&#x7136;&#x540E;&#x5728;&#x7EC8;&#x7AEF;&#x6267;&#x884C;&#x767B;&#x5F55;&#x547D;&#x4EE4;&#xFF0C;&#x8F93;&#x5165;&#x7528;&#x6237;&#x540D;&#x3001;&#x5BC6;&#x7801;&#x3001;&#x90AE;&#x7BB1;&#x5373;&#x53EF;&#x767B;&#x5F55;&#x3002;</p>
<pre class="language-"><code class="lang-js">$ npm login
</code></pre>
<h3 id="5&#x53D1;&#x5E03;&#x5230;-npm"><a name="5&#x53D1;&#x5E03;&#x5230;-npm" class="anchor-navigation-ex-anchor" href="#5&#x53D1;&#x5E03;&#x5230;-npm"><i class="fa fa-link" aria-hidden="true"></i></a>5.&#x53D1;&#x5E03;&#x5230; npm</h3>
<p>&#x6267;&#x884C;&#x53D1;&#x5E03;&#x547D;&#x4EE4;&#xFF0C;&#x53D1;&#x5E03;&#x7EC4;&#x4EF6;&#x5230; npm</p>
<pre class="language-"><code class="lang-js">$ npm publish
</code></pre>
<h3 id="6&#x53D1;&#x5E03;&#x6210;&#x529F;"><a name="6&#x53D1;&#x5E03;&#x6210;&#x529F;" class="anchor-navigation-ex-anchor" href="#6&#x53D1;&#x5E03;&#x6210;&#x529F;"><i class="fa fa-link" aria-hidden="true"></i></a>6.&#x53D1;&#x5E03;&#x6210;&#x529F;</h3>
<p>&#x53D1;&#x5E03;&#x6210;&#x529F;&#x540E;&#x7A0D;&#x7B49;&#x51E0;&#x5206;&#x949F;&#xFF0C;&#x5373;&#x53EF;&#x5728; npm &#x5B98;&#x7F51;&#x641C;&#x7D22;&#x5230;&#x3002;</p>
<h3 id="7&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><a name="7&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;" class="anchor-navigation-ex-anchor" href="#7&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;"><i class="fa fa-link" aria-hidden="true"></i></a>7.&#x4F7F;&#x7528;&#x65B0;&#x53D1;&#x5E03;&#x7684;&#x7EC4;&#x4EF6;&#x5E93;</h3>
<p>&#x5B89;&#x88C5;</p>
<pre class="language-"><code class="lang-js">$ npm install vcolorpicker <span class="token operator">-</span><span class="token constant">S</span>
</code></pre>
<p>&#x4F7F;&#x7528;</p>
<pre class="language-"><code class="lang-js"># &#x5728; main<span class="token punctuation">.</span>js &#x5F15;&#x5165;&#x5E76;&#x6CE8;&#x518C;
<span class="token keyword">import</span> vcolorpicker <span class="token keyword">from</span> <span class="token string">&apos;vcolorpicker&apos;</span>
Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>vcolorpicker<span class="token punctuation">)</span>

# &#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;
<span class="token operator">&lt;</span>template<span class="token operator">&gt;</span>
  <span class="token operator">&lt;</span>colorPicker v<span class="token operator">-</span>model<span class="token operator">=</span><span class="token string">&quot;color&quot;</span> <span class="token operator">/</span><span class="token operator">&gt;</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>template<span class="token operator">&gt;</span>
<span class="token operator">&lt;</span>script<span class="token operator">&gt;</span>
  <span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
    <span class="token function">data</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token punctuation">{</span>
        color<span class="token punctuation">:</span> <span class="token string">&apos;#ff0000&apos;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">&gt;</span>
</code></pre>
<h2 id="&#x53C2;&#x8003;&#x6587;&#x7AE0;"><a name="&#x53C2;&#x8003;&#x6587;&#x7AE0;" class="anchor-navigation-ex-anchor" href="#&#x53C2;&#x8003;&#x6587;&#x7AE0;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53C2;&#x8003;&#x6587;&#x7AE0;</h2>
<p><a href="https://zhuanlan.zhihu.com/p/30948290" target="_blank">&#x4ECE;&#x96F6;&#x5F00;&#x59CB;&#x642D;&#x5EFA;Vue&#x7EC4;&#x4EF6;&#x5E93; VV-UI</a> </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; YoungGary 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-01-03 16:31:06
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="call.html" class="navigation navigation-prev " aria-label="Previous page: 5.模拟实现call和apply">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="microFE.html" class="navigation navigation-next " aria-label="Next page: 7.记一次基于qiankun的微前端的改造">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"6.使用Vue cli3搭建组件库并发布到 npm","level":"1.5.6","depth":2,"next":{"title":"7.记一次基于qiankun的微前端的改造","level":"1.5.7","depth":2,"path":"js/microFE.md","ref":"js/microFE.md","articles":[]},"previous":{"title":"5.模拟实现call和apply","level":"1.5.5","depth":2,"path":"js/call.md","ref":"js/call.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-comscore","prism","-highlight","copy-code-button","search-pro","-search","-lunr","expandable-chapters","splitter","-sharing","tbfed-pagefooter","anchor-navigation-ex"],"styles":{},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy YoungGary 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"],"lang":{"shell":"bash"}},"splitter":{},"search-pro":{},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"theme-comscore":{},"copy-code-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Gary","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Gary的小窝","language":"zh-hans","gitbook":"*","description":"Gary的小窝. 里面包含了个人撰写的技术文章"},"file":{"path":"js/ui.md","mtime":"2020-01-03T08:31:06.074Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-09T14:10:10.930Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

